home *** CD-ROM | disk | FTP | other *** search
/ Speccy ClassiX 1998 / Speccy ClassiX 98.iso / amiga_system / the_aminet / dev / c / asyncio.lha / AsyncIO / src / OpenAsync.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-10  |  832 b   |  44 lines

  1. #include "async.h"
  2.  
  3. #ifdef ASIO_NOEXTERNALS
  4. struct AsyncFile*
  5. OpenAsync(
  6.     _REG( a0 ) const STRPTR fileName,
  7.     _REG( d0 ) OpenModes mode,
  8.     _REG( d1 ) LONG bufferSize,
  9.     _REG( a1 ) struct ExecBase *SysBase,
  10.     _REG( a2 ) struct DosLibrary *DOSBase )
  11. #else
  12. LibCall struct AsyncFile *
  13. OpenAsync(
  14.     _REG( a0 ) const STRPTR fileName,
  15.     _REG( d0 ) OpenModes mode,
  16.     _REG( d1 ) LONG bufferSize )
  17. #endif
  18. {
  19.     static const WORD PrivateOpenModes[] =
  20.     {
  21.         MODE_OLDFILE, MODE_NEWFILE, MODE_READWRITE
  22.     };
  23.     BPTR        handle;
  24.     AsyncFile    *file;
  25.  
  26.     file    = NULL;
  27.  
  28.     if( handle = Open( fileName, PrivateOpenModes[ mode ] ) )
  29.     {
  30. #ifdef ASIO_NOEXTERNALS
  31.         file = AS_OpenAsyncFH( handle, mode, bufferSize, TRUE, SysBase, DOSBase );
  32. #else
  33.         file = AS_OpenAsyncFH( handle, mode, bufferSize, TRUE );
  34. #endif
  35.  
  36.         if( !file )
  37.         {
  38.             Close( handle );
  39.         }
  40.     }
  41.  
  42.     return( file );
  43. }
  44.